package com.fuhe.chen.vendingmachine.dao;

import com.fuhe.chen.vendingmachine.dto.cond.BookOrderCond;
import com.fuhe.chen.vendingmachine.pojo.BookCommodity;
import com.fuhe.chen.vendingmachine.pojo.BookOrder;
import com.fuhe.chen.vendingmachine.pojo.RelationshipBookCommodity;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;

import java.util.List;

@Mapper
public interface BookOrderDao {

    /**
     * 添加新订单
     * @param bookOrder
     */
    void addBookOrder(BookOrder bookOrder);

    /**
     * 根据用户id和订单状态查询订单列表
     * @param userId
     * @param status
     * @return
     */
    List<BookOrder> findOrderByUserId(@Param("userId") String userId, @Param("status") Integer status,@Param("orderId") String orderId);

    /**
     * 根据订单id查询订单信息
     * @param orderId
     * @return
     */
    BookOrder findOrderByOrderId(@Param("orderId") String orderId);

    /**
     * 修改订单信息
     * @param bookOrder
     */
    void updateBookOrder(BookOrder bookOrder);

    /**
     * 添加预订商品信息
     */
    void addBookCommodity(RelationshipBookCommodity relationshipBookCommodity);

    /**
     * 查询预订商品信息
     * @param book_order_id
     */
    List<BookCommodity> findBookCommodity(@Param("book_order_id") String book_order_id);

    List<BookOrder> findOrderByMachineId(@Param("machineId") int machineId,@Param("status")  int status);

    List<BookOrder> findOrderByCondition(BookOrderCond cond);

    Integer findOrderCountByUserId(@Param("userId") String userId, @Param("status") Integer status);

    BookOrder findOrderByPickCode(@Param("machineId") Integer machineId, @Param("pickCode") String pickCode);

    Integer getBookCapacity(@Param("machine_id") Integer machine_id);
}
